<div class="hbox hbox-auto-xs hbox-auto-sm" ng-init="
    app.settings.asideFolded = false;
    app.settings.asideDock = false;
  ">
    <!-- main -->
    <div class="col">
        <!-- main header -->
        <div class="bg-light lter b-b wrapper-md">
            <div class="row">
                <div class="col-sm-6 col-xs-12">
                    <h1 class="m-n font-thin h3 text-black">Jumpserver管理</h1>
                    <!--<small class="text-muted">可访问堡垒机列表管理</small>-->
                </div>
            </div>
        </div>
        <!-- / main header -->
        <div class="wrapper-md">
            <!-- toaster directive -->
            <toaster-container
                    toaster-options="{'position-class': 'toast-top-right', 'close-button':true}"></toaster-container>
            <!-- / toaster directive -->

            <uib-tabset>
                <uib-tab index="0" heading="管理">
                    <div class="panel panel-default" ng-controller="jumpserverCtrl">
                        <div class="panel-body">

                            <div class="form-horizontal col-md-12">
                                <div class="form-group">
                                    <button type="button" class="btn btn-info" ng-click="getJumpserver()"><span
                                            class="glyphicon glyphicon-repeat"></span>刷新
                                    </button>
                                </div>
                            </div>

                            <!--活动会话-->
                            <div class="form-horizontal col-md-12">
                                <!--终端-->
                                <div class="col-md-12">
                                    <uib-accordion close-others="false">
                                        <div uib-accordion-group class="panel-default"
                                             heading="Administrators"
                                             is-open="true" style="box-shadow: 0 0 5px #ddd;padding: 10px;">
                                            <uib-accordion-heading>
                                                <b style="color: #777">活动会话</b>
                                                <span class="label pull-right"
                                                      style="background-color: #2a2a2b; color: white;">TerminalSession</span>
                                            </uib-accordion-heading>

                                            <div style="margin-top: 5px;">

                                                <table class="table table-striped">
                                                    <thead>
                                                    <tr>
                                                        <td><b style="margin-left: 5px; color: #777">用户</b></td>
                                                        <td><b style="margin-left: 5px; color: #777">用户IP</b></td>
                                                        <td><b style="margin-left: 5px; color: #777">系统账户@主机</b></td>
                                                        <td><b style="margin-left: 5px; color: #777">终端</b></td>
                                                        <td><b style="margin-left: 5px; color: #777">协议</b></td>
                                                        <td class="col-md-2"><b style="margin-left: 5px; color: #777">开始时间</b>
                                                        </td>
                                                    </tr>
                                                    </thead>

                                                    <tbody>
                                                    <tr ng-repeat="session in jumpserver.terminalSessions"
                                                        style="font-size:1em;">
                                                        <td>{{session.user}}</td>
                                                        <td>{{session.remote_addr}}</td>
                                                        <td>{{session.system_user}}@{{session.asset}}</td>
                                                        <td>
                                                            <b style="margin-left: 5px; color: #286090">{{session.terminal_name}}</b>
                                                        </td>
                                                        <td>
                                                            <i ng-show="session.protocol == 'ssh'"
                                                               uib-popover-html="'SSH'" popover-trigger="'mouseenter'">
                                                                <embed style="margin-top: 3px;"
                                                                       src="img/simpleicons/keybox.svg" width="15"
                                                                       height="15"
                                                                       type="image/svg+xml"
                                                                       pluginspage="img/simpleicons/"></embed>
                                                            </i>
                                                            <i ng-show="session.protocol == 'rdp'"
                                                               uib-popover-html="'RDP'" popover-trigger="'mouseenter'">
                                                                <embed style="margin-top: 3px;"
                                                                       src="img/simpleicons/server.svg" width="15"
                                                                       height="15"
                                                                       type="image/svg+xml"
                                                                       pluginspage="img/simpleicons/"></embed>
                                                            </i>
                                                        </td>
                                                        <td>{{session.date_start}}</td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </div>

                                        </div>
                                    </uib-accordion>
                                </div>

                            </div>

                            <div class="form-horizontal col-md-6">
                                <div class="col-md-12">
                                    <uib-accordion close-others="false">
                                        <div uib-accordion-group class="panel-default" heading="Jumpserver"
                                             is-open="true" style="box-shadow: 0 0 5px #ddd;padding: 10px;">
                                            <uib-accordion-heading>
                                                <b style="color: #777">Jumpserver</b>
                                                <span class="label pull-right"
                                                      style="background-color: #00a8f3; color: white;">{{jumpserver.host}}</span>
                                            </uib-accordion-heading>
                                            <div class="col-md-12">
                                                <label class="col-md-2 control-label"><span
                                                        style="color: #ec2121;">*</span><b
                                                        style="color : #777">管理账户</b></label>
                                                <div class="col-md-8">
                                                    <ui-select ng-model="nowAdminuser.selected"
                                                               theme="bootstrap">
                                                        <ui-select-match placeholder="搜索管理账户名称......">
                                                            {{$select.selected.username}}
                                                        </ui-select-match>
                                                        <ui-select-choices
                                                                refresh="queryAdminuser($select.search)"
                                                                refresh-dalay="0"
                                                                repeat="item in adminuserList | filter: $select.search">
                                                            <div ng-bind-html="item.username | highlight: $select.search"></div>
                                                        </ui-select-choices>
                                                    </ui-select>
                                                </div>
                                                <div class="col-md-2" style="margin-top: 5px;">
                                                    <button type="button" class="btn btn-xs"
                                                            style="margin-left: 5px; background-color: limegreen; color: white;"
                                                            ng-click="saveAdminuser()"><span
                                                            class="glyphicon glyphicon-ok"></span>保存
                                                    </button>
                                                </div>
                                            </div>

                                            <div class="col-md-12" style="margin-top: 5px;">
                                                <label class="col-md-2 control-label"><span
                                                        style="color: #ec2121;">*</span><b
                                                        style="color : #777">系统账户</b></label>
                                                <div class="col-md-8">
                                                    <ui-select ng-model="nowSystemuser.selected"
                                                               theme="bootstrap">
                                                        <ui-select-match placeholder="搜索系统账户名称......">
                                                            {{$select.selected.username}}
                                                        </ui-select-match>
                                                        <ui-select-choices
                                                                refresh="querySystemuser($select.search)"
                                                                refresh-dalay="0"
                                                                repeat="item in systemuserList | filter: $select.search">
                                                            <div ng-bind-html="item.username | highlight: $select.search"></div>
                                                        </ui-select-choices>
                                                    </ui-select>
                                                </div>
                                                <div class="col-md-2" style="margin-top: 5px;">
                                                    <button type="button" class="btn btn-xs"
                                                            style="margin-left: 5px; background-color: limegreen; color: white;"
                                                            ng-click="saveSystemuser()"><span
                                                            class="glyphicon glyphicon-ok"></span>保存
                                                    </button>
                                                </div>
                                            </div>

                                        </div>
                                    </uib-accordion>
                                </div>

                                <div class="col-md-12">
                                    <uib-accordion close-others="false">
                                        <div uib-accordion-group class="panel-default"
                                             heading="Administrators"
                                             is-open="true" style="box-shadow: 0 0 5px #ddd;padding: 10px;">
                                            <uib-accordion-heading>
                                                <b style="color: #777">超级管理员</b>
                                                <span class="label pull-right"
                                                      style="background-color: #ff8700; color: white;">Administrators</span>
                                            </uib-accordion-heading>
                                            <div>
                                                <label class="col-md-2 control-label"><span
                                                        style="color: #ec2121;">*</span><b
                                                        style="color : #777">用户名</b></label>
                                                <div class="col-md-8">
                                                    <ui-select ng-model="nowUser.selected" theme="bootstrap">
                                                        <ui-select-match placeholder="搜索用户名称......">
                                                            {{$select.selected.username}}
                                                        </ui-select-match>
                                                        <ui-select-choices refresh="queryUser($select.search)"
                                                                           refresh-dalay="0"
                                                                           repeat="item in userList | filter: $select.search">
                                                            <div ng-bind-html="item.username | highlight: $select.search"></div>
                                                        </ui-select-choices>
                                                    </ui-select>
                                                </div>
                                                <div class="col-md-2" style="margin-top: 5px;">
                                                    <button type="button" class="btn btn-xs"
                                                            style="background-color: red; color: white;"
                                                            ng-click="authAdmin()">
                                                        <i class="glyphicon glyphicon-plus"></i>授权
                                                    </button>
                                                </div>
                                            </div>

                                            <div style="margin-top: 5px;">

                                                <table class="table table-striped">
                                                    <thead>
                                                    <tr>
                                                        <td class="col-md-6"><b style="margin-left: 10px; color: #777">管理员</b>
                                                        </td>
                                                        <td class="col-md-6"><b style="margin-left: 10px; color: #777">Email</b>
                                                        </td>
                                                    </tr>
                                                    </thead>

                                                    <tbody>
                                                    <tr ng-repeat="administrator in jumpserver.administrators"
                                                        style="font-size:1em;">
                                                        <td>
                                                            <b style="margin-left: 5px; color: #286090">{{administrator.username}}<{{administrator.name}}></b>
                                                        </td>
                                                        <td>{{administrator.email}}
                                                        </td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </div>

                                        </div>
                                    </uib-accordion>
                                </div>
                            </div>


                            <!--用户/主机-->
                            <div class="form-horizontal col-md-6">
                                <div class="col-md-12">
                                    <uib-accordion close-others="false">
                                        <div uib-accordion-group class="panel-default" heading="Hosts"
                                             is-open="true" style="box-shadow: 0 0 5px #ddd;padding: 10px;">
                                            <uib-accordion-heading>
                                                <b style="color: #777">主机</b>
                                                <span class="label pull-right"
                                                      style="background-color: #00a8f3; color: white;">Hosts</span>
                                            </uib-accordion-heading>
                                            <div>
                                                <b>Local Hosts</b>
                                                <button type="button" class="btn btn-xs"
                                                        style="margin-left: 5px; background-color: limegreen; color: white;"
                                                        ng-click="syncAssets()">
                                                    <i class="fa fa-spin fa-spinner"
                                                       ng-show="btnSyncAssets"></i>
                                                    <i class="icon icon-control-play"
                                                       ng-show="!btnSyncAssets"></i>全量同步主机
                                                </button>
                                                <span class="badge pull-right" style="color: #286090">{{jumpserver.localServersTotal}}</span>
                                            </div>

                                            <div style="margin-top: 10px;">
                                                <b>Jumpserve Hosts</b>
                                                <span class="badge pull-right" style="color: #286090">{{jumpserver.jumpserverAssetsTotal}}</span>
                                            </div>
                                        </div>
                                    </uib-accordion>
                                </div>

                                <div class="col-md-12">
                                    <uib-accordion close-others="false">
                                        <div uib-accordion-group class="panel-default" heading="Users"
                                             is-open="true" style="box-shadow: 0 0 5px #ddd;padding: 10px;">
                                            <uib-accordion-heading>
                                                <b style="color: #777">用户</b>
                                                <span class="label pull-right"
                                                      style="background-color: #ff5f87; color: white;">Users</span>
                                            </uib-accordion-heading>
                                            <div>
                                                <b>Local Users</b>
                                                <button type="button" class="btn btn-xs"
                                                        style="margin-left: 5px; background-color: limegreen; color: white;"
                                                        ng-click="syncUsers()">
                                                    <i class="fa fa-spin fa-spinner"
                                                       ng-show="btnSyncUsers"></i>
                                                    <i class="icon icon-control-play"
                                                       ng-show="!btnSyncUsers"></i>全量同步用户
                                                </button>
                                                <span class="badge pull-right" style="color: #286090">{{jumpserver.localUsersTotal}}</span>
                                            </div>

                                            <div style="margin-top: 10px;">
                                                <b>Jumpserver Users</b>
                                                <span class="badge pull-right" style="color: #286090">{{jumpserver.jumpserverUsersTotal}}</span>
                                            </div>
                                        </div>
                                    </uib-accordion>
                                </div>

                                <!--终端-->
                                <div class="col-md-12">
                                    <uib-accordion close-others="false">
                                        <div uib-accordion-group class="panel-default"
                                             heading="Administrators"
                                             is-open="true" style="box-shadow: 0 0 5px #ddd;padding: 10px;">
                                            <uib-accordion-heading>
                                                <b style="color: #777">终端</b>
                                                <span class="label pull-right"
                                                      style="background-color: #ff8700; color: white;">Terminal</span>
                                            </uib-accordion-heading>

                                            <div style="margin-top: 5px;">

                                                <table class="table table-striped">
                                                    <thead>
                                                    <tr>
                                                        <td class="col-md-3"><b style="margin-left: 10px; color: #777">名称</b>
                                                        </td>
                                                        <td class="col-md-3"><b style="margin-left: 10px; color: #777">IP</b>
                                                        </td>
                                                        <td class="col-md-3"><b style="margin-left: 10px; color: #777">SSH/HTTP</b>
                                                        </td>
                                                        <td class="col-md-3"><b style="margin-left: 10px; color: #777">会话</b>
                                                        </td>
                                                    </tr>
                                                    </thead>

                                                    <tbody>
                                                    <tr ng-repeat="terminal in jumpserver.terminals"
                                                        style="font-size:1em;">
                                                        <td>
                                                            <b style="margin-left: 5px; color: #286090">{{terminal.name}}</b>
                                                        </td>
                                                        <td>{{terminal.remote_addr}}</td>
                                                        <td>{{terminal.ssh_port}}/{{terminal.http_port}}</td>
                                                        <td>{{terminal.session}}</td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </div>

                                        </div>
                                    </uib-accordion>
                                </div>

                            </div>


                        </div>
                    </div>

                </uib-tab>
                <uib-tab index="1" heading="数据校验">
                    <div class="panel panel-default" ng-controller="jumpserverCheckCtrl">
                        <div style="margin-top: 5px;" class="panel">
                            <div class="panel-body">
                                <div class="form-horizontal col-md-12">
                                    <div class="form-group">
                                        <button type="button" class="btn btn-success" ng-click="checkUsers()">
                                            <i class="icon icon-user" ng-show="!btnCheckUsers"></i>
                                            <i class="fa fa-spin fa-spinner" ng-show="btnCheckUsers"></i>校验用户
                                        </button>
                                        <button type="button" class="btn btn-success" ng-click="checkAssets()">
                                            <i class="icon icon-screen-desktop" ng-show="!btnCheckAssets"></i>
                                            <i class="fa fa-spin fa-spinner" ng-show="btnCheckAssets"></i>校验资产
                                        </button>
                                        <button type="button" class="btn btn-info" ng-click="getJumpserver()"><span
                                                class="glyphicon glyphicon-repeat"></span>刷新
                                        </button>
                                    </div>
                                </div>
                                <!--闲置用户-->
                                <div class="form-horizontal col-md-12">
                                    <div class="col-md-12">
                                        <uib-accordion close-others="false">
                                            <div uib-accordion-group class="panel-default"
                                                 heading="Administrators"
                                                 is-open="true" style="box-shadow: 0 0 5px #ddd;padding: 10px;">
                                                <uib-accordion-heading>
                                                    <b style="color: #777">闲置用户</b>
                                                    <span class="label pull-right"
                                                          style="background-color: #ff5f87; color: white;">Users</span>
                                                </uib-accordion-heading>

                                                <div style="margin-top: 5px;">

                                                    <table class="table table-striped">
                                                        <thead>
                                                        <tr>
                                                            <td><b style="margin-left: 5px; color: #777">User</b></td>
                                                            <td><b style="margin-left: 5px; color: #777">Email</b></td>
                                                            <td><b style="margin-left: 5px; color: #777">phone</b></td>
                                                            <td><b style="margin-left: 5px; color: #777">Source</b></td>
                                                            <td class="col-md-4"><b
                                                                    style="margin-left: 5px; color: #777">CreatedBy</b>
                                                            </td>
                                                            <td class="col-md-1"><b
                                                                    style="margin-left: 5px; color: #777">Mgmt</b></td>
                                                        </tr>
                                                        </thead>

                                                        <tbody>
                                                        <tr ng-repeat="user in jumpserver.inactiveUsers"
                                                            style="font-size:1em;">
                                                            <td>{{user.username}}<{{user.name}}></td>
                                                            <td>{{user.email}}</td>
                                                            <td>
                                                                <b ng-show="user.phone != '0'">{{user.phone}}</b>
                                                            </td>
                                                            <td>
                                                                {{user.source}}
                                                            </td>
                                                            <td>
                                                                <b style="margin-left: 5px; color: #286090">{{user.date_joined}}@{{user.created_by}}</b>
                                                            </td>
                                                            <td>
                                                                <button type="button" class="btn btn-xs" ng-show="false"
                                                                        style="margin-left: 5px; background-color: #ef2929; color: white;"
                                                                        ng-click="delUsers(user.id)">
                                                                    <i class="glyphicon glyphicon-remove"></i>删除
                                                                </button>
                                                            </td>
                                                        </tr>
                                                        </tbody>
                                                    </table>
                                                </div>

                                            </div>
                                        </uib-accordion>
                                    </div>
                                </div>

                                <!--闲置资产-->
                                <div class="form-horizontal col-md-12">
                                    <div class="col-md-12">
                                        <uib-accordion close-others="false">
                                            <div uib-accordion-group class="panel-default"
                                                 heading="Administrators"
                                                 is-open="true" style="box-shadow: 0 0 5px #ddd;padding: 10px;">
                                                <uib-accordion-heading>
                                                    <b style="color: #777">闲置资产</b>
                                                    <span class="label pull-right"
                                                          style="background-color: #2ea8e5; color: white;">Assets</span>
                                                </uib-accordion-heading>

                                                <div style="margin-top: 5px;">

                                                    <table class="table table-striped">
                                                        <thead>
                                                        <tr>
                                                            <td><b style="margin-left: 5px; color: #777">Hostname</b>
                                                            </td>
                                                            <td><b style="margin-left: 5px; color: #777">IP</b></td>
                                                            <td><b style="margin-left: 5px; color: #777">Platform</b>
                                                            </td>
                                                            <td><b style="margin-left: 5px; color: #777">CreatedBy</b>
                                                            </td>
                                                            <td class="col-md-1"><b
                                                                    style="margin-left: 5px; color: #777">Mgmt</b></td>
                                                        </tr>
                                                        </thead>

                                                        <tbody>
                                                        <tr ng-repeat="asset in jumpserver.inactiveAssets"
                                                            style="font-size:1em;">
                                                            <td>{{asset.hostname}}</td>
                                                            <td>{{asset.ip}}</td>
                                                            <td>
                                                                {{asset.platform}}
                                                            </td>
                                                            <td>
                                                                <b style="margin-left: 5px; color: #286090">{{asset.created_by}}</b>
                                                            </td>
                                                            <td>
                                                                <button type="button" class="btn btn-xs" ng-show="false"
                                                                        style="margin-left: 5px; background-color: #ef2929; color: white;"
                                                                        ng-click="delAssets(asset.id)">
                                                                    <i class="glyphicon glyphicon-remove"></i>删除
                                                                </button>
                                                            </td>
                                                        </tr>
                                                        </tbody>
                                                    </table>
                                                </div>

                                            </div>
                                        </uib-accordion>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>

                </uib-tab>
            </uib-tabset>
        </div>
    </div>
    <!-- / main -->
</div>

